 var idss = getvl1("idss");
 var ytypeId = getvl("ytypeId");
 var names = getvl1("names");
 var dizhiid = "";

 $(function() {
 	if(idss != '') {
 		selectAlls(idss);
 	}else{
 	}
 });

var zhifujiage =0;
var zongjianshu = "";
var jingbizong =0;
var youhuijuan = 0;
var jingbidikou = "";
var jingbis=0;
var nuber=0;

//新增地址 
function xinzhengdizhi(sizhi){
	$.ajax({
		url: urlcore + "/api/address/selectOne?id="+sizhi,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var da=data.data;
 					dizhiid=da.id;
 			var  zifuchuandizhi="";
 					var zifuchuan=da.province+da.city+da.county+da.address;
 		if(zifuchuan.length>12){
          	zifuchuandizhi+=zifuchuan.substr(0 , 14)+"...";
          }else{
          	zifuchuandizhi+=zifuchuan;
          }
 				var	dizhi = '<ul class="clearfix"><li><span>收&nbsp;&nbsp;货&nbsp;&nbsp;人</span>' + da.userName + '</li>' +
 						'        <li class="a_xiugai_right">' +
 						'            <span>电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;话</span>' + da.userPhone + '</li>' +
 						'        <li><span>收货地址</span>' +zifuchuandizhi+ '</li>' +
 						'    </ul>' +
 						'    <a href="11.2.3dizhi.html?id='+uuuuid+'">修改</a>';
 					$("#dizhi").append(dizhi); //地址信息
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	

}
//获取默认地址 
function dizhi() {
 	$.ajax({
 		url: urlcore + "/api/address/selectDefault",///address/selectDefault3?userid=" + uuuuid,
 		type: "get",
 		dataType: 'json',
 		contentType: "application/json;charset=utf-8",
 		success: function(data) {
 			if(data.success == true) {
 				var da = data.data;
 				
 					var  zifuchuandizhi="";
 				var dizhi = "";
 				if(da != null) {
 					
 					var zifuchuan=da.province+da.city+da.county+da.address;
 		if(zifuchuan.length>12){
          	zifuchuandizhi+=zifuchuan.substr(0,14)+"...";
          }else{
          	zifuchuandizhi+=zifuchuan;
          }
 					dizhiid=da.id;
 					dizhi += '<ul class="clearfix"><li><span>收&nbsp;&nbsp;货&nbsp;&nbsp;人</span>'+da.userName+'</li>' +
 						'        <li class="a_xiugai_right">' +
 						'            <span>电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;话</span>'+da.userPhone+'</li>' +
 						'        <li><span>收货地址</span>'+zifuchuandizhi+'</li>' +
 						'    </ul>' +
 						'    <a href="11.2.3dizhi.html?id='+uuuuid+'">修改</a>';
 				} else {
 					dizhi += '<div class="dingdan_dizhi_wu">'+ 
          '<a href="11.2.3dizhi.html?id='+uuuuid+'"><img src="images/add.png" />添加新地址</a>'+
           '</div>';
 				}
 				$("#dizhi").append(dizhi); //地址信息
 				
 			}
 		},
 		error: function() {
 			/* Act on the event */
 			alert("error");
 		}
 	});
 }
 var dikou = 0;
 var  hejis=0;
 var zongjine = 0;
  var jinbi=0;
 var freightMoneys = 0;
 var zhognjin=0;
 function selectAlls(goodsid) {
	 
 	$.ajax({
 		url: urlcore + "/api/goodsCar/selectGoodsCarList2?ids="+goodsid,//goodsCar/selectGoodsCarList2  /goodsCar/selectGoodsCarList22?
 		type: "get",
 		dataType: 'json',
 		contentType: "application/json;charset=utf-8",
 		success: function(data) {
 			if(data.success == true) {
 				var dingdanxinxi = "";
 				var jianshu = 0;
 				var jiage = 0;
 				var weight=0;
 				jingbis+=data.data.allGoldRate;
 				nuber=data.data.allGoldRate;
 				$.each(data.data, function(y, n) {
 					jianshu = 0;
 					jiage = 0;
 					weight=0;
 	        dingdanxinxi+='<div class="shopgoodsid"><h4 style="background-image:url('+n.headImg+');">' + n.storeName + '</h4><input type="text" style="display: none;" class="dianpuids" name="' + n.id + '" value="' + n.id + '">'+
 					  '<input type="hidden"   id="yun"  value="'+n.freightMoney+'">';
 					  $.each(n.goodsList, function(q, w) {
							dingdanxinxi += '<input type="text" style="display: none;"  name="goodsids' + n.id + '" value="' + w.id + '"> <div name="kuchun' + n.id + '" id="' + w.id + '" class="clearfix tuwen">' +
								'        <div class="tuwen-img fl">' +
								'            <img  src="' +w.coverUrl+ '" width="75" height="75">' +
								'        </div>' +
								'        <div class="tuwen-wenzi">' +
								'            <h5 class="wuye_h01">' + w.goodsTitle + '</h5>' +
								'            <div class="wuye_div01">产品质量均有保障</div>' +
								'        </div>' +
								'    </div>';
								$.each(w.myStockList, function(o, a) {
									dingdanxinxi += ' <div class="dingdan_fenlei clearfix">' +
										'    	<ul class="fl">' +
										'    		<li>颜色：<span>' + a.colour.colourName + '</span></li>' +
										'    		<li>尺码：<span>' + a.size.sizeName + '</span></li>' +
										'    		<li>单价：<span>' + w.goodsCar.packRate+ '元/件</span></li>' +
										'    	</ul>' +
										'    	<div class="fr">' +
										'    		<h5>' + (w.goodsCar.packRate*a.saleNum) + '元</h5>' +
										'    		<h6>' + a.saleNum + '件</h6>' +
										'    	</div>' +
										'    </div>';
 								    weight+=a.saleNum*w.weight;
 							      zongjianshu += a.saleNum;
 							      jianshu += a.saleNum; //jianshu 							
										if(a.saleNum>=w.packNumber){
											jiage +=parseFloat(a.saleNum *  w.goodsCar.packRate); //多少yuan
											zhognjin+=parseFloat(a.saleNum * w.goodsCar.packRate);
										}else{
											jiage += parseFloat(a.saleNum * w.goodsCar.packRate); //多少yuan  
											zhognjin+=parseFloat(a.saleNum * w.goodsCar.packRate);
										}
									
                    if(n.openGold==1){
											 hejis+=jiage*(w.goldRate/100)*40;
											 jinbi=jiage*(w.goldRate/100);
								       dingdanxinxi+='<input type="hidden" class="'+(parseInt(jinbi))+'" value="'+(parseInt(jinbi))+'" id="jinbiss'+n.id+'">';
										}else{
								       dingdanxinxi+='<input type="hidden" class="0" value="0" id="jinbiss'+n.id+'">';
										}
 						    });
 					  });
						dingdanxinxi +='<div class="sell_fabu_guige"><ul><li class="clearfix zhiweifabu02">'+
							'<label>优惠券:</label>'+
							'<span class="xingbie youusers" name="" onclick="youhuijuanthis(this)"  id="'+n.id+'">未选择优惠券</span>'+
							'<input type="hidden" value="'+jiage+'">'+
							'<input type="hidden" name=""  class="youhuijuanss" id="youhuijuan'+n.id+'">'+
							'<div class="payment_time_mask payment_time_mask02">'+
												'<div class="pay_ttl">'+
														'<h4>选择优惠券</h4>'+
														'<span>取消</span>'+
												'</div>'+
												'<ul class="youhuiquan">'+
													'<li id="0"></li>'+
													 '<li id="0"></li>'+
													 '<li id="1">未领取优惠券</li>'+
													 '<li id="0"></li>'+
													 '<li id="0" onclick="guanbi(this)"></li>'+
												'</ul>'+
						'</div>'+
					'</li>';      
 					if(n.freightMoney!=null && n.freightMoney!=0 && n.freightMoney!="") {
 						dingdanxinxi +=
							'<li class="clearfix zhiweifabu00'+n.id+'">'+
							'<input type="hidden"  class="yunfeijiesuan'+n.id+'" value="'+weight.toFixed(2)+'">'+
							'<input type="hidden" name="yunfeijiesuan22" class="yunfeijie3  yunfeijiesuan22'+n.id+'" value="0">'+
							'<label>邮&emsp;寄:</label>'+
							'<span class="xingbie2 youji'+n.id+'" onclick="wulius(this)" name="'+n.id+'" id="wuliumign">选择配送方式</span>'+
							'<div class="payment_time_mask payment_time_mask00'+n.id+'" >'+
								'<div class="pay_ttl">'+
										'<h4>选择邮寄方式</h4>'+
										'<span>取消</span>'+
								'</div>'+
								'<ul>'+
									'<li id="0"  onclick="guanbi(this)" name="'+n.id+'"></li>'+
									 '<li id="1"  onclick="guanbi(this)" name="'+n.id+'">快递</li>'+
									 '<li id="2"  onclick="guanbi(this)" name="'+n.id+'">货运</li>'+
									 '<li id="0" onclick="guanbi(this)" name="'+n.id+'"></li>'+
								'</ul>'+
							'</div>'+
						'</li></ul></div>';      
 					} else {
 						dingdanxinxi +=
						'<li class="clearfix zhiweifabu00'+n.id+'">'+
						'<input type="hidden" class="yunfeijiesuan'+n.id+'" value="'+weight.toFixed(2)+'">'+
						'<input type="hidden"  name="yunfeijiesuan22" class="yunfeijie3 yunfeijiesuan22'+n.id+'" value="0">'+
						'<label>邮&emsp;寄:</label>'+
						'<span class="xingbie2 youji'+n.id+'" onclick="wulius(this)" name="'+n.id+'" id="wuliumign">选择配送方式</span>'+
						'<div class="payment_time_mask payment_time_mask00'+n.id+'" >'+
								'<div class="pay_ttl">'+
										'<h4>选择邮寄方式</h4>'+
										'<span>取消</span>'+
								'</div>'+
								'<ul>'+
									 '<li id="0" onclick="guanbi(this)" name="'+n.id+'"></li>'+
									 '<li id="0" onclick="guanbi(this)"  name="'+n.id+'"></li>'+
									 '<li id="1" onclick="guanbi(this)" name="'+n.id+'">包邮</li>'+
									 '<li id="0" onclick="guanbi(this)"  name="'+n.id+'"></li>'+
									 '<li id="0" onclick="guanbi(this)"  name="'+n.id+'"></li>'+
								'</ul>'+
						'</div>'+
					'</li></ul></div>';      
 					}
 					dingdanxinxi += '<div class="detail_goods_liuyan">买家留言：<input type="text" id="remark' + n.id + '" placeholder="请输入您要留下的话">' +
 						'    </div>'+
 						'    <div class="detail_goods_zhifu">' +
 						'        <span>共计<i>' + jianshu + '</i>件商品</span>' +
 						'        <span>合计：<i>&yen;' + jiage.toFixed(2) + '</i></span>' +
 						'    </div><div class="dingdan_jinbi">' +
 						'	<p class="fl">'+
 						'<input type="text" style="display: none;" id="zj' + n.id + '" value="' + jiage.toFixed(2) + '">' +
 						'<input type="text" style="display: none;" class="' + n.id + '" value="' + jianshu + '"></div>';
 				});
 				$("#dingdanxinxi").append(dingdanxinxi);
 				if(sessionStorage.getItem("dizhiid")!="undefined" && sessionStorage.getItem("dizhiid")!=null){
 					xinzhengdizhi(sessionStorage.getItem("dizhiid"));
 				}else{
 					 dizhi(); 
 				}
 				if(jingbizong != 0 && jingbizong != '') {
 					jingbizong = jingbizong / dikou;
 				}
        var zongmingxiss='<div class="dingdan_jinbi">'+ //jingbis
						'<p class="fl">可用<em id="keyong">金币'+ parseInt(hejis)+'</em>抵扣<em class="dikouss">'+jinbi.toFixed(2)+'</em></p>'+//+dikou+'
						'<div class="dingdan_select fr"  onclick="dianjiss()" >'+ //name="'+dikou+'"
							'<input type="checkbox" id="checkbox-1-1" name="checkWorkshopOverviewItem" class="regular-checkbox">'+ //+n.id+'
							'<label for="checkbox-1-1"></label>'+ //'+n.id+'
								'<input type="hidden" value="" name="dikous">'+ //'+dikou+'
						'</div>'+
					'</div>';
				$(".zongmingxiss").append(zongmingxiss);
				var zongmingxi='<ul id="zongmingxi">'+
							'<li>总金额<span id="shangpingzhongjia">&yen;' + zhognjin.toFixed(2) + '</span><input type="hidden" value="'+zhognjin+'" id="zjtext"></li>' +
							'<li>总运费<span id="zyunf">+&yen;' + freightMoneys + '</span></li>' +
							'<li>优惠券<span id="youhuijz">-&yen;0.0</span><input type="hidden" value="0" id="zyhjtext"></li>'+
							'<li>金币抵扣<span id="jingbis">-&yen;0.0</span><input type="hidden" value="0" id="zjbtext"></li>'+
							'</ul>';
 				$("#zongmingxi").append(zongmingxi);
				$(function () {
				 zhifuzongjine();
					$(".zhiweifabu02>span").click(function () {
							$("#bg").css({
									display: "block", height: $(document).height()
							});
							var $box = $('.payment_time_mask02');
							$box.css({
									display: "block",
							});
							$(".zhaopin_zpzw_em2").css("color","#04a6e9");
							$(".zhiweifabu02 i").addClass("up");
					});
					//点击关闭按钮的时候，遮罩层关闭
					$(".payment_time_mask02 li").on('click',function () {
							$("#bg,.payment_time_mask02").css("display", "none");
							$(".zhiweifabu02>span").text($(this).html());
							$(".zhaopin_zpzw_em2").css("color","#04a6e9");
							$(".zhiweifabu02 i").removeClass("up").addClass("down");
					});
			  });
 		  }else{
 				   window.location.href=history.go(-1);
 		  }	
			$(".pay_ttl span").on('click',function () {
					$("#bg,.payment_time_mask").css("display", "none");
			});
 		},
 		error: function() {
 			alert("error");
 		}
 	});
 }
 //选择配送方式 
 function wulius(te){
 	 /* $(".zhiweifabu01>span").click(function () {});*/
	        $("#bg").css({
	            display: "block", height: $(document).height()
	        });
	        var $box = $('.payment_time_mask00'+$(te).attr("name")+'');
					
	        $box.css({
	            display: "block",
	        });
	        
	        $(".zhaopin_zpzw_em"+$(te).attr("name")+"").css("color","#04a6e9");
	        
	        $(".zhiweifabu00"+$(te).attr("name")+" i").addClass("up");
	  /*  //点击关闭按钮的时候，遮罩层关闭
	    $(".payment_time_mask01 li").on('click',function () {
	        $("#bg,.payment_time_mask01").css("display", "none");
	        $(".zhiweifabu01>span").text($(this).html());
	        $(".zhaopin_zpzw_em1").css("color","#04a6e9");
	        $(".zhiweifabu01 i").removeClass("up").addClass("down");
	    });*/
	   
 }
 
 
 function guanbi(te){ 
    if($(te).attr("id")=="0"){
          $("#bg,.payment_time_mask00"+$(te).attr("name")+"").css("display", "none");
	        $(".zhiweifabu00"+$(te).attr("name")+">span").text("选择配送方式");
	        $(".zhaopin_zpzw_em"+$(te).attr("name")+"").css("color","#04a6e9");
	        $(".zhiweifabu00"+$(te).attr("name")+" i").removeClass("up").addClass("down");
          if(dizhiid!=""){
	        	$.ajax({
							url: urlcore + "/api/expressPrice/selectShopExpressPriceByAddressId?shopId="+$(te).attr("name")+"&addressId="+dizhiid+"&weight="+$(".yunfeijiesuan"+$(te).attr("name")).val(),
							type: "get",
							dataType: 'json',
							contentType: "application/json;charset=utf-8",
							success:function(data){
								if (data.success == true) {
								/*$("#bg,.payment_time_mask00"+$(te).attr("name")+"").css("display", "none");
										$(".zhiweifabu00"+$(te).attr("name")+">span").text($(te).html());
										$(".zhaopin_zpzw_em"+$(te).attr("name")+"").css("color","#04a6e9");
										$(".zhiweifabu00"+$(te).attr("name")+" i").removeClass("up").addClass("down");
												$(".yunfeijiesuan22"+$(te).attr("name")).val(data.data);
												*/
												$(".yunfeijie3").each(function(){
											
														freightMoneys+=parseFloat($(this).val());
													 $("#zyunf").html("&yen;"+freightMoneys);
													 
												});
												 zhifuzongjine();
								}else{
									alert(data.msg);
								}
							},
							error:function() {
								/* Act on the event */
								alert("error");
							}
						});	
          }
               
    }else{
     if(dizhiid!=""){
        $.ajax({
					url: urlcore + "/api/expressPrice/selectShopExpressPriceByAddressId?shopId="+$(te).attr("name")+"&addressId="+dizhiid+"&weight="+$(".yunfeijiesuan"+$(te).attr("name")).val(),
					type: "get",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					success:function(data){
						if (data.success == true) {
						$("#bg,.payment_time_mask00"+$(te).attr("name")+"").css("display", "none");
								$(".zhiweifabu00"+$(te).attr("name")+">span").text($(te).html());
								$(".zhaopin_zpzw_em"+$(te).attr("name")+"").css("color","#04a6e9");
								$(".zhiweifabu00"+$(te).attr("name")+" i").removeClass("up").addClass("down");
										$(".yunfeijiesuan22"+$(te).attr("name")).val(data.data);
										
										$(".yunfeijie3").each(function(){
											
												freightMoneys+=parseFloat($(this).val());
											 $("#zyunf").html("&yen;"+freightMoneys);
											 
										});
										 zhifuzongjine();
						}else{
							alert(data.msg);
						}
					},
					error:function() {
						alert("error");
					}
				});	
     }             
  }
}

var youhui=0;

 function quzhifuss2() {
 	    var sunss=0;
// 			$(".xingbie2").each(function(){
// 					 if(sunss==0){
// 							if($(this).html()=="选择配送方式"){
// 							sunss++;
// 							alert("有商品未选择配送类型");
// 						 }
// 					 }
// 					 
// 			});
 	   if(sunss==0){
 	   		var hh = '[';
				//var hh=[];
			$("#dingdanxinxi").children(".shopgoodsid").find(".dianpuids").each(function(y, n) {
					 var shopids = $(this).val();
					 if($(".youji"+shopids).html()!="选择配送方式"){
							var givetype=0;
							if($(".youji"+shopids).html()=="包邮"){
									givetype=1;
									var youfei=0;
							 }else if($(".youji"+shopids).html()=="快递"){
									givetype=2;
							 }else if($(".youji"+shopids).html()=="货运"){
								givetype=3;
							 }
							var  yunfei=$(".yunfeijiesuan22"+shopids).val();
							if(yunfei=="null"){
									yunfei="0";           //商品运费      
							}          
							
						var remark="null";
						 if($("#remark" + shopids).val()!=""){
							remark=$("#remark" + shopids).val();
						 }; //买家留言
						var jine = $("#zj" + shopids).val();   //每家店铺订单金额
						var youhuijuan=0;
						var youhuiquanid=0;
						 if($("#youhuijuan"+shopids).attr("name")!=""){
							youhuijuan=parseFloat($("#youhuijuan"+shopids)); //优惠券
						 youhuiquanid=$("#youhuijuan"+shopids).attr("name");
						 
						 }
						var jingbidikou=0;
						var jingbidikoushulaing=0;
								 if($("#checkbox-1-1").is(':checked')){
									jingbidikou=parseFloat($("#jinbiss"+shopids).attr("class"));//金币抵扣数量
									jingbidikoushulaing=parseFloat($("#jinbiss"+shopids).val()); //金币抵扣钱
								 }
						var  shijizhifu=0;
						shijizhifu=parseFloat(jine)-parseFloat(youhuijuan)-parseFloat(jingbidikou);
						var goodsNumber = $("." + shopids).val();   //商品数量
						var shopinfo = '';
						$('input[name="goodsids' + shopids + '"]').each(function(){
							var goodssid = $(this).val();
							shopinfo+=goodssid;
						});
				
							if(1==1){                                                                                                                                                                                                                                                                    
							hh += '{"shopId":' + shopids + ',"freightMoney":'+yunfei+',"payMoney":'+shijizhifu+',"orderMoney":' +jine+ ',"goodsNumber":' +goodsNumber+ ',"giveType":' + givetype + ',"payType":' + 0 + ',"addressId":' + dizhiid + ',"goodsId":"' + shopinfo + '","remark":"'+remark+'","goldNum":'+jingbidikoushulaing+',"goldMoney":'+jingbidikou+',"userCouponId":'+youhuiquanid+',"saveMoney":'+youhuijuan+'}';
							
						}else{
							hh += ',{"shopId":' + shopids + ',"freightMoney":'+yunfei+',"payMoney":'+shijizhifu+',"orderMoney":' +jine+ ',"goodsNumber":' +goodsNumber+ ',"giveType":' + givetype+ ',"payType":' + 0 + ',"addressId":' + dizhiid + ',"goodsId":"' + shopinfo + '","remark":"' + remark + '","goldNum":'+jingbidikoushulaing+',"goldMoney":'+jingbidikou+',"userCouponId":'+youhuiquanid+',"saveMoney":'+youhuijuan+'}';
						}
					  
						//window.location.href="12.0.0zhifu_goods.html?orid="+shopids; 
				}else{
					alert("有商品未选择配送类型");
				} //物流
			});
				hh += ']';
			
			 if(hh.length>10){
				 shengcheng(hh);
			 }
 	   }
 }
   function shengcheng(hh){
   	$.ajax({
 		url: urlcore + "/api/order/addValet2",
 		type: "post",
 		contentType: "application/json;charset=utf-8",
 		data: JSON.stringify({
 			"myOrder": hh
 		}),
 		dataType: "json",
 		success: function(data) {
 			if(data.success == true) {
 			      var orid="";
 			      var sun=0;
 			     $.each(data.data, function(y,n) {
                      sun++
                      if(sun==1){
                        orid+=n.id;
                      }else{
                      	 orid+=","+n.id;
                      }
 			     });
 			  
                   if(orid!=""){
                   	  window.location.href="12.0.0zhifu_goods.html?orid="+orid; 
                   }else{
                   	  alert("异常");
                   }
                                			      
 			}
 		},
 		error: function() {
 			alert("error");
 		}
 	});
   }




	    
function youhuijuanthis(te){
	var arr=new Array();  
	$(".allyouhuijuan").each(function(){
		if($(this).attr("name")!="null" && $(this).attr("name")!=""){
           arr.push($(this).attr("name"));
		}
	});
	
	var sts=first(arr);
  dianjiyouhuijuan(sts,$(te).attr("id"),$(te).next().val());
}


//数组去重

/*var str=['hello','node','element','node','hello','blue','red'];*/
var str1="";
function first(args){

	var su=0;
		for(i=0;i<args.length;i++){
				if(str1.indexOf(args[i])<0){
					su++;
					if(su==1){
						str1+=args[i];
					}else{
						str1+=","+args[i];
					}
					 // str1.push(args[i])
				}
		}
		return str1;
		//sessionStorage.setItem("youhuiid",str1);
}

function dianjiyouhuijuan(coupntid,shopid,shomoli){
	$(".youhuiquan").html("");
	$.ajax({
		url: urlcore + "/api/userCoupon/selectAllUserCoupon2?coupntid="+coupntid+"&shopId="+shopid+"&shoplimitMoney="+shomoli,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				   if(data.data.userCouponList!=null && data.data.userCouponList!=""){
				   	
				$.each(data.data.userCouponList, function(y,n) {
					 if(n.coupon!=null){
					 
					 	//alert(JSON.stringify(data.data))
       var youhuiquan='<li id="'+data.data.shopIds+'" class="'+n.coupon.saveMoney+'" name="抵扣￥'+n.coupon.saveMoney+'"  onclick="dikouyouhui(this,'+n.coupon.id+')">'+
                     '抵扣￥'+n.coupon.saveMoney+''+
                      '</li>';
         $(".youhuiquan").append(youhuiquan);
				    }else{
		var youhuiquan='<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>'+
                       '<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>'+
                       '<li  onclick="guanbidikouyouhui(this)">'+
                      '暂无可用优惠券'+
                       '</li>'+
                       '<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>'+
			     '<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>';
				 $(".youhuiquan").append(youhuiquan);
				    }
	});
			}else{
			     var youhuiquan='<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>'+
                       '<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>'+
                       '<li  onclick="guanbidikouyouhui(this)">'+
                      '暂无可用优惠券'+
                       '</li>'+
                       '<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>'+
			     '<li  onclick="guanbidikouyouhui(this)">'+
                       '</li>';
				 $(".youhuiquan").append(youhuiquan);
			}
			
			}else{
				alert(data.msg);
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	

	  
}

	          
var str1="";
    function first(args){
    	var su=0;
        for(i=0;i<args.length;i++){
            if(str1.indexOf(args[i])<0){
            	su++;
            	if(su==1){
            		str1+=args[i];
            	}else{
            		str1+=","+args[i];
            	}
               // str1.push(args[i])
            }
        }
        return str1;
        //sessionStorage.setItem("youhuiid",str1);
    }
  
function  dianjiss(){

	   if($("#checkbox-1-1").is(':checked')){
	   	if(jingbis>=parseInt(hejis)){
		   	 $("#zjbtext").val(jinbi);
		   	   $("#jingbis").html("-&yen;"+jinbi);
		   }else{
		  // 	$("#input").attr("checked","");
		   	$("#checkbox-1-1").attr("checked",false);
		   	 $("#jingbis").html("-&yen;"+0.0);
	   	   	 $("#zjbtext").val(0);
		   	  alert("金币抵扣不足");
		   }
	   }else{
	   	   $("#jingbis").html("-&yen;"+0.0);
	   	   	 $("#zjbtext").val(0);
	   }
		 zhifuzongjine();
}


 zhifuzongjine();
function  zhifuzongjine(){
	var zj=parseFloat($("#zjtext").val())-parseFloat($("#zjbtext").val())+parseFloat(freightMoneys)-parseFloat($("#zyhjtext").val());//.split("¥,");
	$("#quzhifu").val("去支付(" + zj + "元)")
}
/*
zhifujiage = zongjine + freightMoneys - youhuijuan - jingbizong;
 				;
*/

function youhuijuanjisuan(){
	youhui=0;
	$(".youhuijuanss").each(function(){
		  if($(this).val()!="" && $(this).val()!=null){
		  	youhui+=parseFloat($(this).val());
		  	$("#zyhjtext").val(youhui);
		  	$("#youhuijz").html("-&yen;"+youhui);
		  }
	});
	zhifuzongjine();
	   $("#bg,.payment_time_mask02").css("display", "none");
	        $(".zhiweifabu02>span").text($(this).html());
	        $(".zhaopin_zpzw_em2").css("color","#04a6e9");
	        $(".zhiweifabu02 i").removeClass("up").addClass("down");
		  	  
}



//点击优惠卷
function dikouyouhui(te,cuid){
	$(".youusers").each(function(){
		  if($(this).attr("id")==$(te).attr("id")){
		  	   $(this).html($(te).attr("name"));
		  	   $(this).attr("name",cuid);
		  	  $(this).next().next().val("");
		  	  $(this).next().next().val($(te).attr("class"));
		  	  $(this).next().next().attr("name",cuid);
		  } 
	});
	       
	        youhuijuanjisuan();
}

function guanbidikouyouhui(te){
	     $("#bg,.payment_time_mask02").css("display", "none");
	        $(".zhiweifabu02>span").text($(te).html());
	        $(".zhaopin_zpzw_em2").css("color","#04a6e9");
	        $(".zhiweifabu02 i").removeClass("up").addClass("down");
	         youhuijuanjisuan();
}
